﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework8
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Random ramdom = new Random();
            int[] number = Enumerable.Range(0,100).Select(i => ramdom.Next(1,1001)).ToArray();
           
            Console.WriteLine("排序前的数组为：");
            foreach(var num in number)
            {
                Console.Write(num + " ");
            }
            Console.WriteLine();
            //对于生成的数组降序排序
            var sortedNumbers = number.OrderByDescending(num => num);
            //对于生成的数组求和
            int sum = sortedNumbers.Sum();
            //对于生成的数组求平均值
            double average = sortedNumbers.Average();
            Console.WriteLine("排序之后的数组为：");
            foreach(var num in sortedNumbers)
            {
                Console.Write(num + " ");
            }
            Console.WriteLine();
            Console.WriteLine("生成树的总和为：" + sum);
            Console.WriteLine("生成数的平均值为：" + average);
            Console.ReadKey();
        }
    }
}
